package club.hicode.daydayup.abc.condition;

import org.aspectj.weaver.ast.Var;
import org.junit.Test;

import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;

/**
 * 主流程
 * @author Liu Chunfu
 * @date 2018-08-23 下午8:48
 **/
public class MainTest {

	@Test
	public void test2() {
		ReentrantLock lock1 = new ReentrantLock();
		Condition condition1 = lock1.newCondition();

		ReentrantLock lock2 = new ReentrantLock();
		Condition condition2 = lock2.newCondition();

		ReentrantLock lock3 = new ReentrantLock();
		Condition condition3 = lock3.newCondition();


		ConSpeaker conSpeaker1 = new ConSpeaker(condition2, lock1, "a");
		ConSpeaker conSpeaker2 = new ConSpeaker(condition3, lock2, "b");
		ConSpeaker conSpeaker3 = new ConSpeaker(condition1, lock3, "c");

		conSpeaker1.start();
		conSpeaker2.start();
		conSpeaker3.start();

		condition1.signal();


	}
}
